package yt.kpool.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.king.base.adapter.ViewHolderAdapter;
import com.king.base.adapter.holder.ViewHolder;

import java.util.List;

import yt.kpool.R;


public class PopPowAdapter extends ViewHolderAdapter<String> {

    private int selectedPos;//选中的id 没有为-1
    public PopPowAdapter(Context context, List<String> listData) {
        super(context, listData);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, String dataBean, int position) {
        return layoutInflater.inflate(R.layout.item_poppow,null);
    }

    @Override
    public void bindViewDatas(ViewHolder holder, String s, int position) {
        TextView textView=holder.getView(R.id.tv_line);
        if(holder.getAdapterPosition()==getListData().size()-1)
        {
            textView.setVisibility(View.GONE);
        }
        holder.setText(R.id.tv_content,s);

        if (position==selectedPos)
        {
            //选中的项
            ((TextView)holder.getView(R.id.tv_content)).setTextColor(context.getResources().getColor(R.color.system_color));

        }else
        {
            ((TextView)holder.getView(R.id.tv_content)).setTextColor(context.getResources().getColor(R.color.home_top_word));

        }
    }
    /**
     * 设置选中
     * @param i
     */
    public void setSelected(int i)
    {
        selectedPos=i;
        notifyDataSetChanged();
    }

    /**
     * 设置选中id
     */
    public int getSelectedPos() {
        return selectedPos;
    }
}
